﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Weblications.Sango.Environment;
using Pixysoft.Weblications.Sango.Formular;
using Pixysoft.Weblications.Sango.Constant;

namespace Pixysoft.Weblications.Sango.Command.building
{
    partial class SangoBuildingHandler
    {
        public building_queuecooldowninfo building_queuecooldowninfo()
        {
            string userCode = SangoManager.Authentication();

            building_queuecooldowninfo response = ReflectionManager.CreatePojo<building_queuecooldowninfo>();
            response.Succeed = false;

            Entities.Usr_Profile profile = UsrProfileDao.getUsrProfile(userCode);

            Entities.Usr_Queue usrQueue = UsrQueueDao.tryGetRunningQueue(profile.Usercode, CtiQueueTypecodeCollection.BUILDING_UPGRADE);

            if (usrQueue == null)
            {
                response.Message = "无冷却队列";
                return response;
            }

            Entities.Sys_Queue sysQueue = SysQueueHelper.searchByCode(usrQueue.Queueserialcode);

            int goldprice = QueueFormular.getQueueCooldownGoldPrice(usrQueue, sysQueue);

            if (goldprice <= 0)
            {
                response.Message = "无须冷却队列";
                return response;
            }


            response.queuename = sysQueue.Queuetypename;
            response.queuetypecode = usrQueue.Queuetypecode;
            response.queueserialcode = usrQueue.Queueserialcode;
            response.goldprice = goldprice;
            response.Succeed = true;
            return response;
        }


    }
    public interface building_queuecooldowninfo : ISangoResponse
    {
        string queuename { get;set;}
        long queuetypecode { get;set;}
        long queueserialcode { get;set;}
        long goldprice { get;set;}
    }
}
